package org.chnxi.study.design.single;

import java.lang.reflect.Constructor;

public class HolderSingleTest {

    public static void main(String[] args) throws Exception{
        new Thread(()->{
            HolderSingle.InnerClass instance = HolderSingle.getInstance();
            System.out.println(Thread.currentThread().getName()+";instance.hashcode="+instance.hashCode());
        }, "T-1").start();


        new Thread(()->{
            try{
                Constructor<HolderSingle.InnerClass> declaredConstructor = HolderSingle.InnerClass.class.getDeclaredConstructor(null);
                declaredConstructor.setAccessible(true);
                HolderSingle.InnerClass innerClass = declaredConstructor.newInstance();
                System.out.println(Thread.currentThread().getName()+";innerClass.hashcode="+innerClass.hashCode());
            }catch (Exception e){
                e.printStackTrace();
            }
        }, "T-2").start();
    }

}
